<!-- <template>
  <h1>Avue 测试</h1>
  <avue-form :option="formOption" v-model="formData" :submitBtn='false' ></avue-form>
</template>
<script setup>
import { ref } from "vue";
const formData = ref({});
const formOption ={
    column:[
    {
    label: "人员",
    prop: "person",
    span: 8, 
  },
  {
    label: "手机号",
    prop: "phone",
    span: 8,
  },
  {
      label: "地址",
      prop: "address",
      type: "select",
      span: 8,
      dicData: [
        { label: "地址1", value: "address1" },
        { label: "地址2", value: "address2" },
        { label: "地址3", value: "address3" },
        // 添加更多地址选项
      ]
    },
  {
    label: "导入人",
    prop: "importer",
    span: 8,
  },
  {
    label: "导入时间",
    prop: "importTime",
    type: "datetime",
    span: 8,
  },
    ]
}
const submitBtn = () => {
  console.log(formData.value);
};
</script> -->

<!-- <template>
  {{form}}
  <avue-form ref="formRef"
             :option="option"
             v-model="form"
             @submit="handleSubmit"></avue-form>
</template>
<script setup>
import { ref, getCurrentInstance } from 'vue'
//获取this
let { proxy } = getCurrentInstance()
const option = ref({})
const form = ref({})
option.value = {
  submitText: '完成',
  emptyText: '取消',
  printBtn: true,
  submitBtn:false,
  column: [{
    label: '姓名',
    prop: 'name'
  }, {
    label: '年龄',
    prop: 'sex'
  }]
}
form.value = {
  name: '张三',
  sex: 12
}
function handleSubmit (form, done) {
  console.log(form)
  done()
}
</script> -->

<template>
  <avue-form :option="option" v-model="form"></avue-form>
</template>

<script setup>
import { ref } from "vue";

const form = ref({
  text1: 0,
});

const option = ref({
  column: [
    {
      label: "内容1",
      prop: "text1",
      type: "radio",
      control: (val, form) => {
        console.log(val, form);
        if (val === 0) {
          return {
            text2: {
              display: true,
            },
            text3: {
              label: "内容3",
            },
          };
        } else {
          return {
            text3: {
              display: false,
            },
            // text3: {
            //   label: "有没有发现我变了",
            // },
          };
        }
      },
      dicData: [
        {
          label: "显示",
          value: 0,
        },
        {
          label: "隐藏",
          value: 1,
        },
      ],
    },
    {
      label: "内容2",
      prop: "text2",
      display: true,
    },
    {
      label: "内容3",
      prop: "text3",
    },
  ],
});
</script>
